package com.example.lpactivity.fragment.news;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.example.lpactivity.R;

public class ContentActivity extends AppCompatActivity {


    private NewsContentFragment newsContentFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_content_news);

        initDatas();
    }

    private void initDatas() {
        String title = getIntent().getStringExtra("title");
        String contnet = getIntent().getStringExtra("contnet");
        if (title != null && contnet != null) {
            newsContentFragment = (NewsContentFragment) getFragmentManager().findFragmentById(R.id.fm_content);
            newsContentFragment.loadData(new News(title, contnet));
        }


    }

    public static void startNewsContentFragment(Context context, News news) {
        Intent intent = new Intent(context, ContentActivity.class);
        intent.putExtra("title", news.getTitle());
        intent.putExtra("contnet", news.getContent());
        context.startActivity(intent);
    }

}
